package gui.components.objectinfo;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JPanel;

import simulation.Connection;

import lookandfeel.customButton;

public class System_Exit {
	public JPanel createPanelElements(){
		//The button onclick event
		class buttonOnClick implements ActionListener{

			@Override
			public void actionPerformed(ActionEvent e) {
				Connection.getMyVehicle().setLocked(false);
				Connection.getMyTeam().removeUser(Connection.getMe());
				System.exit(1);
			}
			
		}
		JPanel pnlMain = new JPanel(new GridLayout(2,1));
			JLabel exitMessage = new JLabel("<html>In order to stop using the Combat Management System " +
					"<br>press the exit button below.<br><br></html>");
			customButton exit = new customButton("Exit Combat Management System");
			//Add the onclick function
			exit.addActionListener(new buttonOnClick());
			pnlMain.add(exitMessage);
			pnlMain.add(exit);
		//return the panel
		return pnlMain;
	}
}
